package com.edu.exam.enums.organization;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 部门状态枚举
 * 所属模块：F-03 组织架构管理模块
 *
 * <p>定义部门的各种状态，支持部门状态管理和流转控制。</p>
 *
 * @author System
 * @version 1.0.0
 * @since 2025-11-22
 */
public enum DepartmentStatus implements BaseEnum {

    NORMAL("NORMAL", "正常"),
    INACTIVE("INACTIVE", "停用"),
    MERGED("MERGED", "合并");

    private final String code;
    private final String description;

    DepartmentStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public static DepartmentStatus fromCode(String code) {
        if (code == null || code.trim().isEmpty()) {
            throw new IllegalArgumentException("Department status code cannot be null or empty");
        }

        for (DepartmentStatus value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        throw new IllegalArgumentException("Unknown department status code: " + code);
    }

    @Override
    public String toString() {
        return description;
    }
}